
package com.cusro.sesion3;
 
import java.util.Random;
 
import javax.swing.JOptionPane;
 
public class Ejemplo6c {
 

/*
 public static final int LUNES = 1;
 public static final int MARTES = 2;
 public static final int MIERCOLES = 3;
 public static final int JUEVES = 4;
 public static final int VIERNES = 5;
 public static final int SABADO = 6;
 public static final int DOMINGO = 7;
 */

 enum Dias{
 LUNES(1, "Monday"), MARTES(2, "Tuesday"), MIERCOLES(3, "Wednesday"), 
JUEVES(4, "Thursday"), VIERNES(5, "Friday"), SABADO(6, "Saturday"), DOMINGO(7, "Sunday");

 private int orden;
 private String english;

 Dias(int orden, String english) {
 this.orden = orden;
 this.english = english;
 }

 public int getOrden() {
 return this.orden;
 }

 public String getEnglish() {
 return this.english;
 }

 public static Dias findDay(int orden) {

 int[] bucky = new int[10];

 int[] bucky2 = new int[]{1,2,3,4,5};

 Dias[] values = Dias.values();
 for (int i = 0; i < values.length; i++) {
 Dias dia = values[i];
 if (dia.getOrden() == orden) {
 return dia;
 }
 }
 return null;
 }

 public static Dias[] getAll(){
 return Dias.values();
 }

 public static String getAllForYou(){
 Dias[] values = Dias.values();
 String cosa = new String();
 for (int i = 0; i < values.length; i++) {
 Dias dia = values[i];
 cosa += dia.getEnglish() + ", ";
 }
 return cosa;
 }

 };

 /**
 * @param args
 */
 public static void main(String[] args) {
 //?int dia = Integer.parseInt(JOptionPane.show?InputDialog("Ingrese un numero de 1 a 7"));

 Random aleatorio = new Random();
 int x = aleatorio.nextInt(7);

 Dias algunDia = Dias.findDay(x);
 JOptionPane.showMessageDialog(null, "Tenemos estos dias: "+Dias.getAllForYou()+" y ademas genero el dia "+x);


 switch(algunDia) {
 case LUNES: 
JOptionPane.showMessageDialog(null, "Su dia es Lunes");
 break;
 case MARTES: 
JOptionPane.showMessageDialog(null, "Su dia es Martes");
 break;
 case MIERCOLES: 
JOptionPane.showMessageDialog(null, "Su dia es Miercoles");
 break;
 case JUEVES: 
JOptionPane.showMessageDialog(null, "Su dia es Jueves");
 break;
 case VIERNES: 
JOptionPane.showMessageDialog(null, "Su dia es Viernes");
 break;
 case SABADO: 
JOptionPane.showMessageDialog(null, "Su dia es Sabado");
 break;
 case DOMINGO: 
JOptionPane.showMessageDialog(null, "Su dia es Domingo");
 break;
 default:
 JOptionPane.showMessageDialog(null, "Ingreso un un valor incorrecto");
 }
 
}
 
}